//
//  YJSenceListCell.m
//  SnackCourier
//
//  Created by qianfeng01 on 15/7/19.
//  Copyright (c) 2015年 qianfeng01. All rights reserved.
//

#import "YJSenceListCell.h"

@implementation YJSenceListCell

- (void)awakeFromNib {
    CGFloat w =self.contentView.frame.size.width/3.0;
    CGFloat h =self.contentView.frame.size.height;
    for (int i=0; i<3; i++) {
        NSArray *nib= [[NSBundle mainBundle] loadNibNamed:@"YJSenceListView" owner:self options:nil];
        _sView =nib.lastObject;
        _sView.frame =CGRectMake(i*w+1, 0, w, h);
        _sView.tag =101 +i;
        [self.contentView addSubview:_sView];
    }
}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];

    // Configure the view for the selected state
}
-(void)showDataWithArray:(NSMutableArray *)array myblock:(YJSenceListBlock)myblock{
    self.array =array;
    self.myblock =myblock;
    for (int i=0; i<array.count; i++) {
        YJSenceListView *Sviwe =(YJSenceListView *)[self.contentView viewWithTag:i+101];
        [Sviwe showDataWithModel:array[i]];
        [Sviwe addTarget:self action:@selector(Click:)];
    }
}

-(void)Click:(YJSenceListView *)view{
    if (self.myblock) {
        YJSenceListModel *model =self.array[view.tag -101];
        self.myblock(model);
    }
}

@end
